{include file="Public/header" /}
<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
<style></style>
<div class="row">
    <div class="col-md-6" style="width: 100%;">
        <div class="box box-primary">
            <div class="box-header">
                <h3 class="box-title">文章添加</h3>
            </div>
            <form method="post" enctype="multipart/form-data" class="form" action="/admin/post_adds">
                <div class="box-body">
                    <div class="form-group">
                        <label>标题</label>
                        <input type="name" class="form-control" name="title" id="name" placeholder="请输入文章标题" value="{$posts.title}">
                    </div>
                    <div class="form-group">
                        <label >分类</label>
                        <select name="sort" id="" class="form-control">
                            {volist name="sort" id="vo"}
                                <option value="{$vo.id}" >{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="form-group">
                        <label>主图</label>
                        <input type="file" name="image"  style="margin:6px;padding: 6px;width: 220px;font-size: 16px;border: 1px solid #D4D4D4;cursor: pointer;background:#eee;"/>
                        <!--<input type="file" name="img" id="exampleInputFile">-->
                        <img src="{$posts.img}" alt="" style="width: 100px;">
                        <p class="help-block">上传小于2M的图片</p>
                    </div>
                    <div class="form-group">
                        <label>内容</label>
                        <script id="editor" type="text/plain" >{$posts.content}
                         </script></div>
                    <div class="form-group">
                        <label>标签</label>&nbsp;&nbsp;&nbsp;&nbsp;
                        {volist name="tags" id="vo"}
                        <input type="checkbox" name="tags[]" id="tags1" value="{$vo.id}">&nbsp;{$vo.name}&nbsp;&nbsp;&nbsp;
                        {/volist}
                    </div>
                    <div class="form-group">
                        <label>状态</label>&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="radio" name="status" value="1" {if condition="$posts.status eq '1'"}  checked="checked" {/if}>&nbsp;&nbsp;展示&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="radio" name="status" value="2" {if condition="$posts.status eq '2'"} checked="checked" {/if}>&nbsp;&nbsp;    不展示
                    </div>
                </div>
                <div class="box-footer">
                    <button type="submit" class="btn btn-primary">Submit</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');


    function isFocus(e) {
        alert(UE.getEditor('editor').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }

    function setblur(e) {
        UE.getEditor('editor').blur();
        UE.dom.domUtils.preventDefault(e)
    }

    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor').execCommand('insertHtml', value)
    }

    function createEditor() {
        enableBtn();
        UE.getEditor('editor');
    }

    function getAllHtml() {
        alert(UE.getEditor('editor').getAllHtml())
    }

    function getContent() {
        var arr = [];
        arr.push("使用editor.getContent()方法可以获得编辑器的内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('editor').getContent());
        alert(arr.join("\n"));
    }

    function getPlainTxt() {
        var arr = [];
        arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
        arr.push("内容为：");
        arr.push(UE.getEditor('editor').getPlainTxt());
        alert(arr.join('\n'))
    }

    function setContent(isAppendTo) {
        var arr = [];
        arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
        UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
        alert(arr.join("\n"));
    }

    function setDisabled() {
        UE.getEditor('editor').setDisabled('fullscreen');
        disableBtn("enable");
    }

    function setEnabled() {
        UE.getEditor('editor').setEnabled();
        enableBtn();
    }

    function getText() {
        //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
        var range = UE.getEditor('editor').selection.getRange();
        range.select();
        var txt = UE.getEditor('editor').selection.getText();
        alert(txt)
    }

    function getContentTxt() {
        var arr = [];
        arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
        arr.push("编辑器的纯文本内容为：");
        arr.push(UE.getEditor('editor').getContentTxt());
        alert(arr.join("\n"));
    }

    function hasContent() {
        var arr = [];
        arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
        arr.push("判断结果为：");
        arr.push(UE.getEditor('editor').hasContents());
        alert(arr.join("\n"));
    }

    function setFocus() {
        UE.getEditor('editor').focus();
    }

    function deleteEditor() {
        disableBtn();
        UE.getEditor('editor').destroy();
    }

    function disableBtn(str) {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            if (btn.id == str) {
                UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
            } else {
                btn.setAttribute("disabled", "true");
            }
        }
    }

    function enableBtn() {
        var div = document.getElementById('btns');
        var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
        for (var i = 0, btn; btn = btns[i++];) {
            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
        }
    }

    function getLocalData() {
        alert(UE.getEditor('editor').execCommand("getlocaldata"));
    }

    function clearLocalData() {
        UE.getEditor('editor').execCommand("clearlocaldata");
        alert("已清空草稿箱")
    }
</script>
{include file="Public/footer" /}